package com.otaku.controller.pool;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import edu.uci.ics.crawler4j.crawler.CrawlController;
import edu.uci.ics.crawler4j.crawler.WebCrawler;

public class ControllerPool {
	private static final Logger log = Logger.getRootLogger();
	
	private static List<MyCrawlerController> cl = new ArrayList<MyCrawlerController>();
	
	public static void run(){
		for(MyCrawlerController cc : cl){
			cc.run();
		}
		
		for(MyCrawlerController cc : cl){
			cc.getCc().waitUntilFinish();
			log.warn(cc.getClassName().getName()+" controller end");
		}
	}
	
	public static void addController(MyCrawlerController cc){
		cl.add(cc);
	}
	
	public static void removeController(int i){
		cl.remove(i);
	}
}
